package com.kly.user.db.dao;
import cn.hutool.core.date.DateTime;
import com.fqgj.common.api.Page;
import com.fqgj.common.base.BaseMapper;
import com.kly.user.db.dbo.FilterOnlineUserCustomerDBO;
import com.kly.user.db.dbo.ModelUserSendMsgNumDBO;
import com.kly.user.db.dbo.UserAfDBO;
import com.kly.user.db.dbo.UserWlmDBO;
import com.kly.user.db.entity.UserEntity;
import com.kly.user.db.entity.UserGreetingContentEntity;
import com.kly.user.db.entity.UserRelationEntity;
import com.kly.user.db.entity.UserWlmEntity;
import com.kly.user.enums.LikeEnum;
import com.kly.user.enums.OnlineStatus;
import com.kly.user.enums.UserStatus;

import java.util.Date;
import java.util.List;

/**
* User: linqu
* Date: 2023-05-24
* Time: 10:10:36.921
*/
public interface UserWlmDao  extends BaseMapper<UserWlmEntity> {

    /**
     * 查询推荐用户
     * @param userCode
     * @return
     */
    List<UserWlmEntity> selectByUserCode(String userCode);

    /**
     * 根据userCode, wlmUserCode查询当前wlm用户
     * @param userWlmEntity
     * @return
     */
    List<UserWlmEntity> selectByWlmUserCode(UserWlmEntity userWlmEntity);

    /**
     * 获取wlm列表
     * @param entity
     * @return
     */
    List<UserWlmEntity> queryUserRelationByFriendUserCode(UserWlmEntity entity);

    List<UserWlmEntity> wlmList(String userCodeFriend, Page page);

    List<UserWlmEntity> queryOnlineWlmList(String userCode);

    /**
     * 获取wlm数量
     * @param entity
     * @return
     */
    int queryUserRelationNum(UserWlmEntity entity);

    List<UserWlmDBO> needSendFlashMsgList(Integer limitNum);

    /**
     * 删除wlm数据
     */
    int removeByUserCode(String userCode);

    /**
     * 互相喜欢记录
     */
    List<UserWlmEntity> queryLikeEachOtherList(String userCode, Page page);
    /**
     * 互相喜欢记录
     */
    List<UserWlmEntity> queryLikeEachOtherList(String userCode);

    /**
     * 根据model对应的在线用户列表
     */
    List<UserWlmEntity> queryOnlineMatchedList(String userCode);
    /**
     * 拉黑、举报等操作
     */
    Integer doAction(String userCode, String userCodeFriend, Integer op, String reason);
    /**
     * like/dislike/pass 超过有效时间
     */
    List<UserWlmEntity> queryLoseEffectiveRecords(int likeType, Date date);
    /**
     * like/dislike/pass 超过有效时间
     */
    int queryLoseEffectiveTotal(int likeType, Date date);
    /**
     * like/dislike/pass 超过有效时间, 重新放回陌生人池
     */
    int reBackToStranger(int likeType, Date date);
    /**
     * 更新flashChat
     */
    int updateFlashChatRecord(String userCode, String userCodeWlm);
    /**
     * Likes Back
     */
    int likesBack(String userCode, String userCodeWlm);
    /**
     * 指定时间内接收到wlm数量
     */
    int receivedWlmNum(String userCode, LikeEnum likeEnum, OnlineStatus onlineStatus, int minutes);
    /**
     * 指定时间内接收到wlm数量
     */
    int receivedWlmNum(String userCode, int likeType, DateTime dateTime);
    /**
     * 当日接收到wlm数量
     */
    int queryContactNumToday(String userCode, String userCodeWlm, LikeEnum likeType);
    /**
     * 查询用户对model发起like的记录
     */
    List<UserWlmEntity> queryLikeMeForModel(Page page);
    /**
     * 查询用户对model发起like总记录数
     */
    int queryLikeMeForModelTotal();
    /**
     * 指定时间内用户发起喜欢操作的数量
     */
    int userLike(String userCode, int likeType, DateTime dateTime);

    /**
     * 用于指定时间内收到like back数量查询
     */
    int receivedLikeBackNum(String userCode, LikeEnum likeType, OnlineStatus onlineStatus, DateTime dateTime);

    /**
     * 获取用户收到的最近一条like back时间
     */
    UserWlmEntity receivedMaxLikeBackTime(String userCode);

    /**
     * 查询建联用户记录
     */
    List<UserWlmEntity> queryConnectRecord(String userCode, String userCodeWlm);

    List<FilterOnlineUserCustomerDBO> listOnlineUserChats(List<String> customerCodes,List<String> modelCodes);

    /**
     * 查找flashchat记录
     */
    List<UserWlmEntity> queryFlashchatRecords(String userCode);

    List<UserWlmEntity>  getTodayWlmRecords(String userCode);

    List<UserWlmEntity> getTodayRecordsByWmlCode(String  wmlUserCode,List<Integer> types);

    List<UserWlmEntity> getRecordsByWmlCodeV2(String  wmlUserCode,Boolean isToday);

    List<UserWlmEntity>  getWlmRecordsV2(String userCode,Boolean isToday);

    /**
     * 超过指定时限，重回陌生人池
     */
    int removeOverEffectiveRecord(String userCode, String userCodeWlm, LikeEnum likeEnum);

    UserWlmEntity getRelation(String fromUser,String toUser);

    void clearLikeExpiredRelation(Integer expiredMins);

    void clearWLMExpiredRelation(Integer expiredMins);

    void clearPassExpiredRelation(Integer expiredMins);

    void clearWlmButNotMatchExpiredRelation(Integer expiredMins);

    void clearDislikeExpiredRelation(Integer expiredMins);

    /**
     * 读取最近下发wlm的记录
     * @param userCode
     * @return
     */
    UserWlmEntity  getLastWlmRecord(String userCode);

    /**
     * 读取当天记录数
     * @param wlmTypes
     * @param userCode
     * @return
     */
    Integer getCountByWmlCode(List<Integer> wlmTypes, String userCode);

    /**
     * 读取当天LIKE记录数
     * @param wlmTypes
     * @param userCode
     * @return
     */
    Integer getCountByLikesCode(List<Integer> wlmTypes, String userCode);

    /**
     * 读取最新的like back 记录
     * @param userCode
     * @return
     */
    UserWlmEntity getLastLKRecord(String userCode);

    /**
     * 判断是否被拉黑
     * @param userCode
     * @param userCodeWlm
     * @return
     */
    int getBlackCount(String userCode, String userCodeWlm);

    /**
     * 判断是否通过wlm like建联
     * @param userCode
     * @param userCodeWlm
     * @return
     */
     int getMatchCount(String userCode, String userCodeWlm);

    /**
     * 获取af建联用户
     */
    List<UserAfDBO> listConnectUsersLatestDayFromAppflyers();


    int getLikeCount(String userCode);


    /**
     *
     * @param userCodes
     * @param contactTime
     * @return
     */
    int getConnectionCount(List<String> userCodes, Date contactTime);

    /**
     * 获取model在线建联用户
     */
    List<ModelUserSendMsgNumDBO> listOnlineUserChats(String modelUserCode);

    List<UserWlmEntity> listCustomerLbModel(String customerCode, List<String> modelCodes);

    /**
     * 获取与指定用户存在关联关系的记录
     */
    List<UserWlmEntity> listUserWlmList(List<String> userCodes, String userCode);

    /**
     * 查询当天存在flashchat建联记录
     */
    List<UserWlmEntity> listContactRelationByFlashchat();

}